home *** CD-ROM | disk | FTP | other *** search
File List | 1995-11-01 | 1.1 KB | 39 lines |
- short madaline_output(short outputs[],char choice,short A)
- {
- int i,result,sum;
-
- /* use the AND method */
- if (choice == 'a' || choice == 'A') {
- result = 1; /* start out with TRUE result */
- for (i = 0;i < A;i++) {
- if (outputs[i] == -1) { /* when first -1 found... */
- result = -1; /* set result */
- break; /* and terminate */
- }
- }
- }
-
- /* use the OR method */
- if (choice == 'o' || choice == 'O') {
- result = -1; /* start out with FALSE result */
- for (i = 0;i < A;i++) {
- if (outputs[i] == 1) { /* when first 1 found... */
- result = 1; /* set result */
- break; /* and terminate */
- }
- }
- }
-
- /* use the MAJORITY method */
- if (choice == 'm' || choice == 'M') {
- sum = 0;
- for (i = 0;i < A;i++)
- sum += outputs[i]; /* sum up all outputs */
- if (sum > 0) result = 1;
- else result = -1;
- }
-
- return result;
- }
- /* ends madaline_output */
-